#include "nad_hbox.h"
#include "../GlobalVars/vars.h"
#include "../TextureFunctions/texturefunctions.h"
#include <GL/gl.h>

// Camera parameters:
//	Look-from = (6.43509, 5.55276, 5.95764)
//	Look-at = (1.65625, 1.96863, 1.1788)
//	Look-up = (0, 1, 0)
//	Clipping, near = 0.01, far = 1e+006
//	Field-of-view = 0.489957, image-aspect-ratio = 1.33333
//	Window size = (0.666667, 0.5), focal-distance = 10

// Current light source name = "defaultambient"
//	Light = Ambient
//	color = (1, 1, 1)
//	intensity = 1

// Polygons for object 'hbox #1' (12 polygons)

	void
hbox(int a)
{
	static GLfloat VertexData[] = {
		0.688164f, 2.93671f, 2.14688f, 0.688164f, 2.93671f, 2.14688f, 0.688164f, 2.93671f, 2.14688f, 
		0.688164f, 1.00055f, 2.14688f, 0.688164f, 1.00055f, 2.14688f, 
		0.688164f, 1.00055f, 2.14688f, 2.62434f, 2.93671f, 2.14688f, 
		2.62434f, 2.93671f, 2.14688f, 2.62434f, 2.93671f, 2.14688f, 
		2.62434f, 1.00055f, 2.14688f, 2.62434f, 1.00055f, 2.14688f, 
		2.62434f, 1.00055f, 2.14688f, 2.62434f, 2.93671f, 0.210716f, 
		2.62434f, 2.93671f, 0.210716f, 2.62434f, 2.93671f, 0.210716f, 
		2.62434f, 1.00055f, 0.210716f, 2.62434f, 1.00055f, 0.210716f, 
		2.62434f, 1.00055f, 0.210716f, 0.688164f, 2.93671f, 0.210716f, 
		0.688164f, 2.93671f, 0.210716f, 0.688164f, 2.93671f, 0.210716f, 
		0.688164f, 1.00055f, 0.210716f, 0.688164f, 1.00055f, 0.210716f, 
		0.688164f, 1.00055f, 0.210716f
	};
	static GLfloat NormalData[] = {
		0.000000f, 1.00000f, 0.000000f, -1.00000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.00000f, 
		0.000000f, -1.00000f, 0.000000f, -1.00000f, 0.000000f, 0.000000f, 
		0.000000f, 0.000000f, 1.00000f, 0.000000f, 1.00000f, 0.000000f, 
		1.00000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 1.00000f, 
		0.000000f, -1.00000f, 0.000000f, 1.00000f, 0.000000f, 0.000000f, 
		0.000000f, 0.000000f, 1.00000f, 0.000000f, 1.00000f, 0.000000f, 
		0.000000f, 0.000000f, -1.00000f, 1.00000f, 0.000000f, 0.000000f, 
		0.000000f, -1.00000f, 0.000000f, 0.000000f, 0.000000f, -1.00000f, 
		1.00000f, 0.000000f, 0.000000f, 0.000000f, 1.00000f, 0.000000f, 
		-1.00000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, -1.00000f, 
		0.000000f, -1.00000f, 0.000000f, -1.00000f, 0.000000f, 0.000000f, 
		0.000000f, 0.000000f, -1.00000f
	};
	static GLfloat TexCoordData[] = {
		0.000000f, 0.000000f, 1.00000f, 1.00000f, 0.000000f, 1.00000f, 
		0.000000f, 1.00000f, 1.00000f, 0.000000f, 
		0.000000f, 0.000000f, 1.00000f, 0.000000f, 
		0.000000f, 1.00000f, 1.00000f, 1.00000f, 
		1.00000f, 1.00000f, 0.000000f, 0.000000f, 
		1.00000f, 0.000000f, 1.00000f, 1.00000f, 
		0.000000f, 1.00000f, 1.00000f, 1.00000f, 
		1.00000f, 0.000000f, 0.000000f, 0.000000f, 
		1.00000f, 0.000000f, 0.000000f, 1.00000f, 
		0.000000f, 1.00000f, 1.00000f, 1.00000f, 
		0.000000f, 0.000000f, 0.000000f, 0.000000f, 
		1.00000f, 0.000000f
	};
	static GLint Indices[] = {
		2, 5, 8, 5, 11, 8, 7, 10, 14, 10, 17, 14, 13, 16, 20, 16, 
		23, 20, 19, 22, 1, 22, 4, 1, 18, 0, 12, 0, 6, 12, 3, 21, 
		9, 21, 15, 9
	};

	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2, GL_FLOAT, 0, TexCoordData);
	glEnableClientState(GL_NORMAL_ARRAY);
	glNormalPointer(GL_FLOAT, 0, NormalData);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, VertexData);

	OGL_Set_Current_Material_Parameters(32.0000f, 1.00000f, 1.00000f, 1.00000f, 0.000000f, 0.000000f, 0.000000f);

	// Set a new diffuse texture map
        if (a==0) OGL_Set_Current_Texture_Map(holz1, 1.00000f, 1.00000f, 0.000000f, 0.000000f);
	if (a==1) OGL_Set_Current_Texture_Map(holz2, 1.00000f, 1.00000f, 0.000000f, 0.000000f);
	if (a==2) OGL_Set_Current_Texture_Map(holz3, 1.00000f, 1.00000f, 0.000000f, 0.000000f);
	if (a==3) OGL_Set_Current_Texture_Map(holz4, 1.00000f, 1.00000f, 0.000000f, 0.000000f);



	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[0]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[3]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[6]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[9]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[12]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[15]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[18]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[21]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[24]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[27]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[30]);
	glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[33]);
}	// End of polygons for object 'hbox #1'
